package com.liwq.base.juc;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

/**
 * @author : liwq
 * @version : 1.0
 * @date : 2023/1/30
 **/
public class ReentReadWriteLockTest {

    public static void main(String[] args) {
        ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
        ReentrantReadWriteLock.WriteLock writeLock = lock.writeLock();

        ReentrantReadWriteLock.ReadLock readLock = lock.readLock();
        writeLock.lock();
        System.out.println("写锁上锁了");
        readLock.lock();
        System.out.println("读锁上锁了");


//        writeLock.unlock();
//        readLock.unlock();

    }
}
